#pragma once

#pragma pack(1)

#define TIMESTAMP_BUFFER_SIZE 18
#define DATE_BUFFER_SIZE 8
#define TIME_BUFFER_SIZE 9


#define CODE_TYPE_LEN 12
#define CODE_STR_LEN 32
#define COORDINATE_LEN 4*4

//const QString cstrDateFormat = "yyyyMMdd";
//const QString cstrTimeFormat = "HHmmsszzz";

enum MsgId
{
	MSG_BROADCASTMSG = 1001,
	MSG_TCPHEARTBEAT = 2001,
	MSG_CHECKINFO = 2002,
	MSG_CODERESULTINFO = 2003,
	MSG_SETIPADDRESS = 3001,
	MSG_SYSINFO = 3002,
	MSG_UNITINFO = 3003,
	MSG_IMGUPLOADTCPHEARTBEAT = 4001,
	MSG_IMGUPLOAD = 4002,
    MSG_CARNUMBER = 5001
};

typedef int _MsgId;

struct _broadcastMsg
{
	int id;//1001
	char ip[16];
	int portNo;
	int portNo2;
    _broadcastMsg()
        :id(MSG_BROADCASTMSG),
        ip("192.168.1.102"),
        portNo(7778),
        portNo2(7779)
    {}

};

//session data from client.
struct _tcpHeartbeat
{
	//int id;//2001
	int status;
};

struct _checkInfo
{
	//int id;//2002
	int exposureTime;
	int gain;
	int imgMode;
	int dist_Cam2Triggle;
	int triggleDelay;
	int flashTimer;
	int triggleInterval;
	int _485portNum;
	int triggleMode;
};



struct _CodeResultPreFixedInfo
{
	//int id;//2003
	char timeStamp[TIMESTAMP_BUFFER_SIZE];
    int codeNum;
};

struct _PackageGeomtryInfo
{
    int nLocation;
    int nVolumeMsgOk;
    int nLength;
    int nWidth;
    int nHeight;
    int nVolume;
    int nXLU;
    int nYLU;
    int nXRU;
    int nYRU;
    int nXLL;
    int nYLL;
    int nXRL;
    int nYRL;
    _PackageGeomtryInfo()
        :nLocation(0),
        nVolumeMsgOk(0),
        nLength(0),
        nWidth(0),
        nHeight(0),
        nVolume(0),
        nXLU(0),
        nYLU(0),
        nXRU(0),
        nYRU(0),
        nXLL(0),
        nYLL(0),
        nXRL(0),
        nYRL(0) {}
};

struct _CodeResultVarInfo
{
    char codeType[CODE_TYPE_LEN];
    char codeStr[CODE_STR_LEN];
    char pix_x[COORDINATE_LEN];
    char pix_y[COORDINATE_LEN];

    bool operator==(const _CodeResultVarInfo& rhs)
    {
        bool bEq = true;
        for (size_t i = 0; i < CODE_STR_LEN; i++)
        {
            if (this->codeStr[i] != rhs.codeStr[i])
            {
                bEq = false;
                break;
            }
        }

        return bEq;
    }

    bool operator!=(const _CodeResultVarInfo& rhs)
    {
        return !operator==(rhs);
    }
};

struct _CodeResultPostFixedInfo
{
    int disposeTime;
    int packageNo;
};



#define RECV_DATA_LENGTH_FOR_SESSION 1024


struct _setIpAddress
{
	//int id;//3001
	char ip[16];
	char mask[16];
};

struct _sysInfo
{
	//int id; //3002
	int exposureTime;
	int gain;
	int imgMode;
};

struct _unitInfo
{
	//int id;//	3003
	int type;
	int value;
};

struct _ImageDataHeader
{
    //int id;//4002
    char timeStamp[TIMESTAMP_BUFFER_SIZE];
    int codeNum;
    int frameSeq;
    char imgType[4];
    int imgLen;

    _ImageDataHeader()
    {
    }
    _ImageDataHeader(_ImageDataHeader*pSrc)
    {
        memcpy(timeStamp, pSrc->timeStamp, TIMESTAMP_BUFFER_SIZE);
        codeNum = pSrc->codeNum;
        memcpy(imgType, pSrc->imgType, 4);
        imgLen = pSrc->imgLen;
    }
};

#pragma pack()